package com.example.product.mapper;


import com.example.common.annotation.AutoFill;
import com.example.model.product.pojo.Product;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ProductMapper {

    List<Product> page(String name, String description);
    @AutoFill
    @Insert("insert into sm.goods( name,category_id, price, `desc`, picture, discount, order_num) VALUES (#{name},#{categoryId},#{price},#{desc},#{picture},#{discount},#{orderNum})")
    void save(Product product);


    void deleteById(List<Integer> ids);

    @Select("SELECT * from sm.goods where product_id=#{id}")
    Product selectById(Integer id);

    @Update("update sm.goods set name=#{name},price=#{price},picture=#{picture},`desc`=#{desc} , discount =#{discount},order_num=#{orderNum},category_id=#{categoryId} where product_id=#{id}")
    void update(Product product);

}
